package com.cal.utms.action.maintenance;

import java.util.List;

import com.cal.utms.dto.maintenance.DelevaryMethodDto;
import com.cal.utms.model.maintenance.MasterDataModel;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class DelevaryMethodAction extends ActionSupport implements ModelDriven<DelevaryMethodDto> {

	private static final long serialVersionUID = 1L;
	private DelevaryMethodDto delevaryMethodDto = new DelevaryMethodDto();
	private MasterDataModel dataModel = new MasterDataModel();
	private String deliverymethods;

	public String saveDeliveryMethod() {
		dataModel.saveDeliveryMethod(deliverymethods, delevaryMethodDto);
		return Action.SUCCESS;
	}

	public String getDelevaryMethods() {
		List<DelevaryMethodDto> delevaryMethodDtos = dataModel.getDelevaryMethods();
		if (delevaryMethodDtos != null) {
			delevaryMethodDto.setDelevaryMethodDtos(delevaryMethodDtos);
			delevaryMethodDto.setSuccess(true);
			delevaryMethodDto.setResultMsg("SUCCESS");
		} else {
			delevaryMethodDto.setSuccess(false);
			delevaryMethodDto.setResultMsg("No Records");
		}
		return Action.SUCCESS;
	}

	public DelevaryMethodDto getDelevaryMethodDto() {
		return delevaryMethodDto;
	}

	public void setDelevaryMethodDto(DelevaryMethodDto delevaryMethodDto) {
		this.delevaryMethodDto = delevaryMethodDto;
	}

	@Override
	public DelevaryMethodDto getModel() {
		return delevaryMethodDto;
	}

	public String getDeliverymethods() {
		return deliverymethods;
	}

	public void setDeliverymethods(String deliverymethods) {
		this.deliverymethods = deliverymethods;
	}

}
